package cn.itcast.consumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;


//@SpringBootApplication   //声明一个启动器
//@EnableDiscoveryClient   //开启Eureka客户端发现功能
//@EnableCircuitBreaker    //开启熔断器,和@EnableHystrix效果类同
//@EnableHystrix    //开启熔断器,和@EnableCircuitBreaker效果类同
@SpringCloudApplication   //相当于@SpringBootApplication+@EnableDiscoveryClient+@EnableCircuitBreaker三个注解合一
@EnableFeignClients    //开启Feign服务
public class ConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
    }

    /**
     * 注册RestTemplate,并采用负载均衡
     *
     * @return
     */
    @Bean
    @LoadBalanced   //开启负载均衡
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }


    /**
     * 注册RestTemplate
     * @return
     */
    /*@Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }*/
}
